<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      //     //1 请使用for循环输出下面图像
      document.write('第一题三角形图案如下<br>')
      for (var i = 0; i < 6; i++) {
        for (var j = 1; j <= i; j++) {
          document.write('*')
        }
        document.write('<br>')
      }

      //   // 2输出七个随机整数，要求5个随机整数（范围再1-99），不能有重复的，后2个随机整数范围再（10-20），也不可以重复
      var arr = []
      for (var i = 0; i < 5; i++) {
        arr[i] = Math.ceil(Math.random() * 99)
        for (var j = 0; j < i; j++) {
          if (arr[i] == arr[j]) {
            i--
          }
        }
      }
      console.log(arr)
      var arr1 = []

      for (var i = 0; i < 2; i++) {
        arr1[i] = Math.floor(Math.random() * 11 + 10)
        for (var j = 0; j < i; j++) {
          if (arr[i] == arr[j]) {
            i--
          }
        }
      }
      console.log(arr1)
      var arr2 = arr.concat(arr1)
      console.log(arr2)
      document.write('第二题答案如下<br/><br>' + arr2 + '<br/><br>')

      //第三题3请统计下面数组中值的数据类型分别有多少个?并输出最多的是哪个数据类型多少个?最少的是哪个数据类型多少个?
      document.write('第三题答案如下<br/><br>')
      var arr = [
        'a',
        1,
        'b',
        2,
        false,
        false,
        true,
        null,
        function () {},
        { a: 1 },
        { v: 8 },
        Number(2),
        '0',
        null,
        { a: 2 },
        '888',
        1,
        3,
        4,
        5,
        false,
        function () {},
      ]

      var string = []
      var number = []
      var boolean = []
      var object = []
      var fn = []
      for (var i = 0; i < arr.length; i++) {
        if (typeof arr[i] == 'string') {
          string.push(arr[i])
        } else if (typeof arr[i] == 'number') {
          number.push(arr[i])
        } else if (typeof arr[i] == 'boolean') {
          boolean.push(arr[i])
        } else if (typeof arr[i] == 'object') {
          object.push(arr[i])
        } else if (typeof arr[i] == 'function') {
          fn.push(arr[i])
        }
      }
      console.log(string)
      console.log(number)
      console.log(boolean)
      console.log(object)
      console.log(fn)
      document.write('string类型的有' + string.length + '个<br>')
      document.write('number' + number.length + '个<br>')
      document.write('boolean' + boolean.length + '个<br>')
      document.write('object' + object.length + '个<br>')
      document.write('function类型的有' + fn.length + '个<br><br>')
      document.write('number类型最多有' + number.length + '个<br>')
      document.write('function类型最少有' + fn.length + '个<br>')

      document.write('<br><br>第四题答案如下<br><br>')
      var month = prompt('请输入月份')

      switch (month) {
        case '1':
          document.write('水瓶座')
          break
        case '2':
          document.write('双鱼座')
          break
        case '3':
          document.write('白羊座')
          break
        case '4':
          document.write('金牛座')
          break
        case '5':
          document.write('双子座')
          break
        case '6':
          document.write('巨蟹座')
          break
        case '7':
          document.write('狮子座')
          break
        case '8':
          document.write('处女座')
          break
        case '9':
          document.write('天枰座')
          break
        case '10':
          document.write('天蝎座')
          break
        case '11':
          document.write('射手座')
          break
        case '12':
          document.write('魔羯座')
          break
        default:
          document.write('输入错误请输入1-12月的值')
      }

      document.write('<br><br>第五题答案如下<br><br>')
      var years = prompt('请输入一个年份')
      if (years % 4 == 0 && years % 100 != 0) {
        document.write('是闰年')
      } else if (years % 400 == 0) {
        document.write('是闰年')
      } else {
        document.write('不是闰年')
      }
    </script>
  </body>
</html>
